# --- 阶段 1: 构建环境 (使用 Node.js) ---
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
RUN chmod +x /app/node_modules/.bin/vite
COPY . .
RUN npm run build

# --- 阶段 2: 运行环境 (使用 Nginx) ---
FROM nginx:stable-alpine
WORKDIR /usr/share/nginx/html
RUN rm -rf ./*

COPY --from=build /app/dist .

COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]